home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / graphics / amicad / arexx_english / center.amicad < prev    next >
Text File  |  1999-12-06  |  1KB  |  65 lines

  1. /* Centering the reference and the value of a component.
  2. $VER: Centrer.AmiCAD 1.00e, © R.Florac, 19 octobre 1998 */
  3.  
  4. options results
  5.  
  6. signal on error
  7. signal on syntax
  8.  
  9. nc=0; objet=1
  10. 'SAVEALL(-1):OBJECTS(-1)'; objets=result
  11. do while objet>0
  12.     'O=FINDOBJ('objet',1,-1,-1)'; objet=result
  13.     if objet>0 then do
  14.     'TEST(O)'
  15.     if result>0 then do
  16.         nc=nc+1
  17.         call centrer(objet)
  18.     end
  19.     objet=objet+1
  20.     if objet>objets then objet=0
  21.     end
  22. end
  23.  
  24. if nc=0 then do
  25.     'PICKOBJ("Click on the objet to arrange")'
  26.     objet=result
  27.     if objet <= 0 then exit
  28.     call centrer(objet)
  29. end
  30.  
  31. exit
  32.  
  33. centrer: procedure
  34.     parse arg o
  35.     'GETPOS(O='o')'; p=result
  36.     'R=GETREF(O)'
  37.     if result>0 then do
  38.     if p=1 | p=3 then do
  39.         'MOVE(R,0,LINE(O)-LINE(R)+(HEIGHT(O)+HEIGHT(R))/2)'
  40.     end
  41.     else do
  42.         'MOVE(R,COL(O)-COL(R)+(WIDTH(O)-WIDTH(R))/2,0)'
  43.     end
  44.     end
  45.     'V=GETVAL(O)'
  46.     if result>0 then do
  47.     if p=1 | p=3 then do
  48.         'MOVE(V,0,LINE(O)-LINE(V)+(HEIGHT(O)+HEIGHT(V))/2)'
  49.     end
  50.     else do
  51.         'MOVE(V,COL(O)-COL(V)+(WIDTH(O)-WIDTH(V))/2,0)'
  52.     end
  53.     end
  54. return
  55.  
  56. /* Traitement des erreurs, interruption du programme */
  57. syntax:
  58. erreur=RC
  59. 'MESSAGE("Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  60. exit
  61.  
  62. error:
  63. 'MESSAGE("Error in line 'SIGL'")'
  64. exit
  65.